<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>FileSetAttrib</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>FileSetAttrib</h1>

<p>Changes the attributes of one or more files or folders. Wildcards are supported.</p>

<pre class="Syntax">FileSetAttrib, Attributes [, FilePattern, OperateOnFolders?, Recurse?]</pre>
<h3>Parameters</h3>
<dl>

  <dt>Attributes</dt>
  <dd><p>The attributes to change (see Remarks).</p></dd>

  <dt>FilePattern</dt>
  <dd>The name of a single file or folder, or a wildcard pattern such as <code>C:\Temp\*.tmp</code>. <em>FilePattern</em> is assumed to be in <a href="../Variables.htm#WorkingDir">%A_WorkingDir%</a> if an absolute path isn't specified.
    <p>If omitted, the current file of the innermost enclosing <a href="LoopFile.htm">File-Loop</a> will be used instead.</p></dd>

  <dt>OperateOnFolders?</dt>
  <dd><p>0 (default) Folders are not operated upon (only files). <br>
1 All files and folders that match the wildcard pattern are operated upon.<br>
2 Only folders are operated upon (no files).</p>
      <p>Note: If FilePattern is a single folder rather than a wildcard pattern, it will always be operated upon regardless of this setting.</p>
      <p>This parameter can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd>

  <dt>Recurse?</dt>
  <dd><p>0 (default) Subfolders are not recursed into.<br>
      1 Subfolders are recursed into so that files and folders contained therein are operated upon if they match <em>FilePattern</em>. All subfolders will be recursed into, not just those whose names match <em>FilePattern</em>.  However, files and folders with a complete path name longer than 259 characters are skipped over as though they do not exist. Such files are rare because normally, the operating system does not allow their creation.</p>
      <p>This parameter can be an <a href="../Variables.htm#Expressions">expression</a>.</p></dd>

</dl>

<h3>ErrorLevel</h3>
<p><span class="ver">[v1.1.04+]</span> This command is able to throw an exception on failure. For more information, see <a href="Catch.htm#RuntimeErrors">Runtime Errors</a>.</p>
<p><a href="../misc/ErrorLevel.htm">ErrorLevel</a> is set to the number of files that <u>failed</u> to be changed or 0 otherwise.</p>
<p>If files were found, <a href="../Variables.htm#LastError">A_LastError</a> is set to 0 (zero) or the result of the operating system's GetLastError() function immediately after the last failure. Otherwise A_LastError contains an error code that might indicate why no files were found.</p>

<h3>Remarks</h3>
<p>The <em>Attributes</em> parameter consists of a collection of operators and attribute letters.</p>
<p><em>Operators</em>:</p>
<table class="info" style="width:574px">
  <tr>
    <td width="23">+</td>
    <td width="535">Turn on the attribute</td>
  </tr>
  <tr>
    <td>-</td>
    <td>Turn off the attribute</td>
  </tr>
  <tr>
    <td>^</td>
    <td>Toggle the attribute (set it to the opposite value of what it is now)</td>
  </tr>
</table>
<p><br>
  <em>Attribute letters</em>:<br>
  R = READONLY<br>
  A = ARCHIVE<br>
  S = SYSTEM<br>
  H = HIDDEN<br>
  N = NORMAL (this is valid only when used without any other attributes)<br>
  O = OFFLINE<br>
T = TEMPORARY</p>
<p>Note: Currently, the compression state of files cannot be changed with this command.</p>
<h3>Related</h3>
<p><a href="FileGetAttrib.htm">FileGetAttrib</a>, <a href="FileGetTime.htm">FileGetTime</a>, <a href="FileSetTime.htm">FileSetTime</a>, <a href="FileGetSize.htm">FileGetSize</a>, <a href="FileGetVersion.htm">FileGetVersion</a>, <a href="LoopFile.htm">File-loop</a></p>
<h3>Examples</h3>
<pre class="NoIndent">FileSetAttrib, +RH, C:\MyFiles\*.*, 1  <em>; +RH is identical to +R+H</em>
FileSetAttrib, ^H, C:\MyFiles  <em>; Toggle the folder's &quot;hidden&quot; attribute.</em>
FileSetAttrib, -R+A, C:\New Text File.txt
FileSetAttrib, +A, C:\*.ini, , 1  <em>; Recurse through all .ini files on the C drive.</em></pre>

</body>
</html>
